<?php
/**
 * 获得用户信息动作类
 * @author yaoli<yaoli@pateo.com.cn>
 * @version 1.0 GetUser add by yaoli<yaoli@pateo.com.cn> 
 */
class card extends ActionBase {
	
	private $date = null;
	
	function init() {
		
	}
	
	/**
	 * 动作
	 *
	 * @see AActionBase::action()
	 */
	public function action() {
		$this->template ();
		$this->template->display ( 'card.htm' );
	}
	
	public function image() {
		// cho '大家好';
		
		#header ( "Content-type: image/png" );
		
		//新建一个真彩色图像
		
		#dump($_REQUEST);
	#	exit;
	 $this->doImage($_REQUEST['context'],'xujinglei.ttf',40);
		
		/*$str = ob_get_contents();
		ob_end_clean();
		echo base64_encode($str);*/
		#echo $str;
	}
	
	function doImage($text,$font = 'xujinglei.ttf',$txtsize=20){
		
		
		#生成图片大小 
		
		$txtcount = abslength($text);
		
		$width = ($txtcount)*($txtsize+6);
		$height = $txtsize*2;
		
		ob_start();
		$im = imagecreatetruecolor ( $width, $height );
		
		header ( "Content-type: image/png" );
		// Create some colors
		$white = imagecolorallocate ( $im, 255, 255, 255 );
		$grey = imagecolorallocate ( $im, 128, 128, 128 );
		$black = imagecolorallocate ( $im, 0, 0, 0 );
		
		$font=DATA_ROOT.'/fonts/'.$font;
		
		//设置背景颜色
		imagefilledrectangle ( $im, 0, 0, $width-1, $height-1, $white );
		
		// Replace path by your own font path
		
		
		// 给文字添加阴影
		#imagettftext ( $im, $txtsize, 0, 11, 21, $grey, $font, $text );
		
		#1、图片 2、字体大小 3、文字旋转角度 4、x轴 5、y轴 6、颜色 7、字体 8、文字
		
		// 添加文字
		imagettftext ( $im, $txtsize, 0, 0,40+3, $black, $font, $text );
		
		//生成图片
		imagepng ( $im);
		//销毁图片
		imagedestroy ( $im );
	}
	

}
